using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Reflection;

namespace MapEditor
{
    public partial class SaveFrm : Form
    {
        static public Bitmap saveBitmap;
        int index = 1;
        public SaveFrm()
        {
            InitializeComponent();

            Program.backGround = Properties.Resources.g1;
            Program.path = Properties.Resources.t1;
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            switch (comboBox1.SelectedIndex)
            { 
                case 0:
                    Program.path = Properties.Resources.t1;
                    break;
                case 1:
                    Program.path = Properties.Resources.t2;
                    break;
                case 2:
                    Program.path = Properties.Resources.t3;
                    break;
                case 3:
                    Program.path = Properties.Resources.t4;
                    break;
                case 4:
                    Program.path = Properties.Resources.t5;
                    break;
                case 5:
                    Program.path = Properties.Resources.t6;
                    break;
                case 6:
                    Program.path = Properties.Resources.t7;
                    break;
            }
        }

        private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
        {
            switch (comboBox2.SelectedIndex)
            {
                case 0:
                    Program.backGround = Properties.Resources.g1;
                    break;
                case 1:
                    Program.backGround = Properties.Resources.g2;
                    break;
                case 2:
                    Program.backGround = Properties.Resources.g3;
                    break;
                case 3:
                    Program.backGround = Properties.Resources.g4;
                    break;
                case 4:
                    Program.backGround = Properties.Resources.g5;
                    break;
                case 5:
                    Program.backGround = Properties.Resources.g6;
                    break;
                case 6:
                    Program.backGround = Properties.Resources.g7;
                    break;
                case 7:
                    Program.backGround = Properties.Resources.g8;
                    break;
            }
        }

        static public string startup;
        private void SaveFrm_Load(object sender, EventArgs e)
        {
            startup = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase);
        }

        private void button1_Click(object sender, EventArgs e)
        {
            PreviewFrm form = new PreviewFrm();
            form.ShowDialog();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            SaveFrm.saveBitmap.Save(SaveFrm.startup + "\\map" + index.ToString() + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
            SaveFrm.saveBitmap.Save("\\map" + index.ToString() + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);

            index++;

            MessageBox.Show("Save complete");
        }
    }
}